<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Work extends Model
{
    protected $casts = ['data' => 'array', 'type' => 'integer'];
    protected $fillable = ['type', 'question', 'data'];

    public function course()
    {
        return $this->belongsTo(Course::class);
    }

    public function users()
    {
        return $this->belongsToMany(User::class)->using(UserWork::class)->withPivot('result')->withTimestamps();
    }
}
